package com.apps.hello.web;

import com.apps.hello.clients.MsgService;
import com.apps.hello.clients.MsgServiceHystrix;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * describe:
 * hello API 调用rpc  msgService,进行负载均衡调用
 *
 * @author zhangyue
 * @date 2019/06/03
 */
@RestController
public class HelloController {

  @Value("${server.port}")
  String port;

  @Resource
  private MsgService msgService;

  @GetMapping(value = "/ribbon")
  public String ribbon(@RequestParam String name) {
    return msgService.listMsg( name );
  }

  @GetMapping(value = "/hystrix")
  public String hystrix(@RequestParam String name) {
    return msgService.infoMsg( name );
  }

  @GetMapping("/hi")
  public String list(@RequestParam(value = "name", defaultValue = "apps") String name) {
    return "hi " + name + " ,hi i am from port:" + port;
  }



}
